<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图表高度测试</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: Arial, sans-serif;
            background: #f0f0f0;
        }
        
        .test-container {
            height: 100vh;
            display: flex;
            flex-direction: column;
            background: white;
        }
        
        .test-header {
            background: #4facfe;
            color: white;
            padding: 10px 20px;
            text-align: center;
        }
        
        .test-controls {
            background: #f8f9fa;
            padding: 10px 20px;
            border-bottom: 1px solid #ddd;
        }
        
        .test-chart-container {
            flex: 1;
            background: #fff;
            border: 2px solid #007bff;
            margin: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            color: #007bff;
        }
        
        .info {
            background: #e9ecef;
            padding: 10px 20px;
            font-size: 14px;
        }
        
        button {
            background: #007bff;
            color: white;
            border: none;
            padding: 8px 16px;
            border-radius: 4px;
            margin-right: 10px;
            cursor: pointer;
        }
        
        button:hover {
            background: #0056b3;
        }
    </style>
</head>
<body>
    <div class="test-container">
        <div class="test-header">
            <h1>图表高度测试页面</h1>
            <p>这个页面用于测试全屏布局和图表高度设置</p>
        </div>
        
        <div class="test-controls">
            <button onclick="showInfo()">显示尺寸信息</button>
            <button onclick="toggleFullscreen()">切换全屏</button>
            <button onclick="window.location.href='klineChart.html'">打开K线图表</button>
        </div>
        
        <div class="test-chart-container" id="chartArea">
            <div>
                <h2>模拟图表区域</h2>
                <p>这里应该显示K线图表</p>
                <p id="sizeInfo">点击"显示尺寸信息"查看当前尺寸</p>
            </div>
        </div>
        
        <div class="info">
            <strong>布局说明：</strong>
            <ul>
                <li>页面使用 height: 100vh 占满整个视口</li>
                <li>使用 flex 布局，图表区域设置为 flex: 1</li>
                <li>图表区域会自动占用剩余的所有空间</li>
                <li>这与 klineChart.html 的布局逻辑完全相同</li>
            </ul>
        </div>
    </div>

    <script>
        function showInfo() {
            const container = document.getElementById('chartArea');
            const containerRect = container.getBoundingClientRect();
            const windowInfo = {
                viewportWidth: window.innerWidth,
                viewportHeight: window.innerHeight,
                containerWidth: containerRect.width,
                containerHeight: containerRect.height
            };
            
            document.getElementById('sizeInfo').innerHTML = `
                <strong>当前尺寸信息：</strong><br>
                视口大小: ${windowInfo.viewportWidth} x ${windowInfo.viewportHeight}px<br>
                图表区域: ${windowInfo.containerWidth} x ${windowInfo.containerHeight}px<br>
                图表高度占比: ${((containerRect.height / window.innerHeight) * 100).toFixed(1)}%
            `;
            
            console.log('尺寸信息:', windowInfo);
        }
        
        function toggleFullscreen() {
            if (!document.fullscreenElement) {
                document.documentElement.requestFullscreen();
            } else {
                document.exitFullscreen();
            }
        }
        
        // 页面加载时显示信息
        window.addEventListener('load', showInfo);
        
        // 窗口大小变化时更新信息
        window.addEventListener('resize', () => {
            setTimeout(showInfo, 100);
        });
    </script>
</body>
</html>

